<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        body {
            font-size: 30px;
        }
        p , h3 {
            padding: 0;
            margin: 0;
        }
    </style>
</head>
<body>
    <h3>页面(2)</h3>
    <p></p>
    <p></p>

    <script>
        // 获取cookie 
        var _data = document.cookie;
        // console.log(_data);
        // 如果有cookie数据 ,就执行以下代码
        if(_data.length != 0){
            // 切换cookie字符串
            var arr = _data.split("; ");
            console.log(arr);

            // 获取标签
            var elements = document.querySelectorAll("p");

            elements[1].innerHTML = arr[0].split("=")[1];
            elements[0].innerHTML = arr[1].split("=")[1];
        }

    </script>
</body>
</html>